package com.china08.yxyapi.api.comm;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.db.res.YxyResType;
import com.china08.yxyapi.repository.db.YxyResTypeRepository;

import io.swagger.annotations.ApiOperation;

@CrossOrigin
@RestController
public class TypeAllController extends YxyApiBaseController {

    @Autowired
    private YxyResTypeRepository yrtr;

    @ApiOperation(value = "获得全部类型")
    @RequestMapping(value = "/api_yw/comm/type/all", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<RespModel> find() {
        List<YxyResType> types = new ArrayList<YxyResType>();
        List<RespModel> list = new ArrayList<TypeAllController.RespModel>();
        List<String> notList = new ArrayList<String>();
        // notList.add("jl13");
        notList.add("jl11");
        types = yrtr.findByIdNotInOrderByOrderNum(notList);
        for (YxyResType yxyResType : types) {
            RespModel model = new RespModel();
            model.id = yxyResType.getId();
            model.name = yxyResType.getName();
            list.add(model);
        }
        return list;
    }

    protected static class RespModel {
        public String id;
        public String name;
    }

}
